package org.lcc.mapper;

import lombok.Data;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ScoreAnalysisMapper {
    @Select("SELECT COUNT(*) > 0 FROM score_analysis WHERE exam_id = #{examId} AND class_id = #{classId}")
    boolean checkAnalysisExists(@Param("examId") Integer examId, @Param("classId") Integer classId);

    @Insert("INSERT INTO score_analysis (exam_id, class_id, average_score, highest_score, lowest_score, analysis_data, create_time) " +
            "VALUES (#{examId}, #{classId}, #{averageScore}, #{highestScore}, #{lowestScore}, #{analysisData}, NOW())")
    void insertAnalysis(@Param("examId") Integer examId,
                        @Param("classId") Integer classId,
                        @Param("averageScore") Double averageScore,
                        @Param("highestScore") Integer highestScore,
                        @Param("lowestScore") Integer lowestScore,
                        @Param("analysisData") String analysisData);
}
